package com.iot.core.data.service;

import com.iot.core.data.BaseQto;
import com.iot.core.data.mapper.MyBaseMapper;

import java.io.Serializable;

public interface IService<T> {
    MyBaseMapper<T> getMapper();
    MyBaseMapper<T> getBaseMapper();

    default   int insert(T entity  ){
        return getMapper().insert(entity);
    }

    default   int updateById(T entity  ){
        return getMapper().updateById(entity,true);
    }

    default   int deleteById(T entity  ){
        return getMapper().deleteById(entity,true);
    }
    default   int delete(BaseQto qm){
        var entity=getById(qm.getId() );
        return getMapper().deleteById(entity,true);
    }

    default T  getById(Long id){
        return  getMapper().getById(id);
    }
    default T  getById(BaseQto qm){
        return  getMapper().getById(qm);
    }
}
